// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程：https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
const uniCaptcha = require('uni-captcha')

module.exports = {
  uniVerifyCaptchaCode: async function(scene, captcha) {
    resCode = 3
    resMsg = "未验证"
    await uniCaptcha.verify({
      scene,
      captcha
    }).then(res => {
      console.log(res)
      console.log(res.code)
      console.log(res.code == 0)
      if (res.code == 0) {
        console.log("success");
        resCode = 0
        resMsg = "验证成功"
      } else {
        console.log("uuuu");
        resCode = 1
        resMsg = "验证失败"
      }
    })
    return {
      code: resCode,
      msg: resMsg
    }
  }

  // 发送短信验证码:
  // getSmsCode:
  // function(phone) {
  //   uniCloud.httpclient.request('https://localhost:8443/restful-api/getCode', {
  //     method: 'GET',
  //     data: {phone: phone}
  //   }

  //  function(code, phone) {
  //    return new Promise((resolve, reject) => {
  //      uniCloud.callFunction({
  //        name: 'sendSms',
  //        data: {
  //          code: code,
  //          phone: phone
  //        }

}
